﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Vortex.SceneFramework.CSS {

	///<summary>Contains information about style property value. Also each value has own importance which is used for style computation.</summary>
	public struct StyleValue {
		public const uint DEFAULT_IMPORTANCE = uint.MinValue;
		public const uint MAX_IMPORTANCE = uint.MaxValue;

		/// <summary>
		/// Empty style value
		/// </summary>
		public static readonly StyleValue Empty = new StyleValue(null, DEFAULT_IMPORTANCE);

		///<summary>Global importance counter</summary>
		private static uint _importanceCounter = 0;

		///<summary>The internal importance of this value</summary>
		private uint _importance;
		/// <summary>Object which represents this value</summary>
		private object _value;

		#region Properties

		/// <summary>
		/// Gets the value object.
		/// </summary>
		/// <value>The value object.</value>
		public object Value {
			get { return _value; }
		}

		/// <summary>
		/// Gets the importance of this value.
		/// </summary>
		/// <value>The importance.</value>
		public uint Importance {
			get { return _importance; }
		}

		#endregion

		/// <summary>
		/// Initializes a new instance of the <see cref="StyleValue"/> struct with custom importance value.
		/// </summary>
		/// <param name="value">The value object.</param>
		/// <param name="importance">The importance value.</param>
		public StyleValue(object value, uint importance) {
			_value = value;
			_importance = importance;
		}

		/// <summary>
		/// Promotes the importance history counter.
		/// </summary>
		/// <returns>Latest autogenerated importance value.</returns>
		public static uint PromoteImportance() {
			return ++_importanceCounter;
		}
	}
}
